/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  CCell,
  Cell,
  Table,
  TableBody,
  TableRow,
  Text,
  TableHead,
  useTheme,
  RCell,
  LineColumn,
  InputLine,
  CheckSwitch,
  Select,
  BlobInputList,
} from "customize-easy-ui-component";
import {DirectLink} from "../../routing/Link";
import {multilines2Html, zdBoth} from "../tools";
import {item资料审查o, MaterialReview} from "./editorReview";
import {objNestSet} from "../../common/tool";

//承压的相似度更高点
export const 资料审查报告= ({theme, orc, rep} :{theme: any, orc:any, rep:any}
) => {
  return <>
    <div css={{
      display: 'flex',
      justifyContent: 'space-between'
    }}>
      <Text>单位内部编号：{orc.单位内部编号}</Text>
      <Text>报告编号：{rep.isp.no}</Text>
    </div>
    <Table  fixed={ ["13%","9%","9%","9%","%"]  } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <DirectLink  href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/MaterialReview#MaterialReview`}>
        <TableRow>
          <CCell>审查项目</CCell><CCell colSpan={3}>审查结果</CCell><CCell>缺失情况</CCell>
        </TableRow>
        { item资料审查o.map(([name,title,initIsp]: any, i:number) => {
            const isGaizl='改资料'===name;         //【注意】特殊部分；配置总会有遗漏的，容易造成不一致性差错。
            return <React.Fragment key={i}><TableRow>
              <CCell rowSpan={initIsp? 2:1}>{title}</CCell>
              <CCell>( {'齐全'===orc?.[name]?.q&&'√'} )齐全</CCell><CCell>( {'缺失'===orc?.[name]?.q&&'√'} )缺失</CCell><CCell>( {'无资料'===orc?.[name]?.q&&'√'} )无资料</CCell>
              { orc?.[name]?.l ?
                  <Cell rowSpan={initIsp? 2:1}>{multilines2Html(orc?.[name]?.l,  (txt,i)=>{
                    return <React.Fragment key={i}>{(i!==0)&&<br/>}<Text>{txt}</Text></React.Fragment>
                  })}</Cell>
                :
                <CCell rowSpan={initIsp? 2:1}>／</CCell>
              }
            </TableRow>
            { initIsp &&
              <TableRow>
                <CCell colSpan={isGaizl? 2:3}>( {orc?.[name]?.s&&'√'} )非首次定期检验</CCell>
                { isGaizl &&
                    <CCell>( { !(orc?.[name]) &&'√'} )无此项</CCell>
                }
              </TableRow>
            }
            </React.Fragment>
        }) }
        </DirectLink>
      </TableBody>
    </Table>
    <Table  fixed={ ["4%","%"]  } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <DirectLink  href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/PreviousQuestion#PreviousQuestion`}>
        <TableRow>
          <CCell rowSpan={2} split={true}>上次定期检验问题记载</CCell>
          <Cell>上次定期检验报告编号：
            {  multilines2Html(orc.上次报告 || '／',  (txt,i)=>{
              return <React.Fragment key={i}>{(i!==0)&&<br/>}<Text>{txt}</Text></React.Fragment>
            } ) }<br/>
            上次定期检验安全状况等级评为： {orc.上次评级 || '／'} 级。
          </Cell>
        </TableRow>
        <TableRow>
          <Cell split={true}>（注明上次定期检验发现的主要缺陷及处理情况）<br/>
            {  multilines2Html(orc.上次缺处 || '／',  (txt,i)=>{
              return <React.Fragment key={i}>{(i!==0)&&<br/>}<Text css={{whiteSpace:'break-spaces'}}>{txt}</Text></React.Fragment>
          } ) }</Cell>
        </TableRow>
        </DirectLink>
      </TableBody>
    </Table>
    <Table fixed={ ["62%","%"]  }  css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <TableRow>
          <CCell><div css={{height: '100%',display: 'flex',justifyContent: 'space-between',alignContent: 'space-between',alignItems: 'flex-start'}}>
            <div><Text>检验人员：</Text>    </div>
            <div css={{textAlign: 'end'}}><Text >日期</Text>2022-12-31</div>
          </div></CCell>
          <CCell><div css={{height: '100%',display: 'flex',justifyContent: 'space-between',alignContent: 'space-between',alignItems: 'flex-start'}}>
            <div><Text >校核人员：</Text>  </div>
            <div css={{textAlign: 'end'}}><Text >日期</Text>2021-01-31</div>
          </div></CCell>
        </TableRow>
      </TableBody>
    </Table>
  </>;
};


//为【支持数学公式正常显示】多行文本设置： <Text css={{whiteSpace:'break-spaces'}}>{txt}</Text> 保留连续的空格的位置占用。
